All Questions
13 questions
2votes
1answer
312views
Wordpress Gutenberg Custom Block the viewScript does not get loaded on the frontend when my block is inserted
I recently developed a custom Gutenberg block by utilizing the @wordpress/create-block package, which effectively generated a full plugin framework. I simply needed to tweak some existing files to get ...
1vote
1answer
274views
Custom gutenberg block refuses to load viewScript and I don't know why
I've been struggling with this for hours. I used the @wordpress/create-block package to generate a template for me to create my first block. I've managed to create a hero block with an image uploader ...
0votes
0answers
630views
Using Google Analytics in an enqueued JS file
I have a JS file custom-head.js that I have enqueued to run in the header as noted in functions.php here: function enqueue_files() { wp_enqueue_script( 'head_scripts', ...
1vote
1answer
703views
Adding tawk.to code just before body tag on functions.php file
I would like to add tawk.to widget script just before the body tag. I would like to add the code to the functions.php file of my child theme. How can I do this? A code sample will assist a long way. ...
1vote
0answers
144views
How to inject variables into public-facing JS using wp_enqueue_script
I'm using wp_enqueue_script to enqueue the public-facing JS of my WP plugin: wp_enqueue_script($this->PluginName, plugin_dir_url(__FILE__) . 'js/public.js', array(), $this->version, false); And ...
0votes
1answer
327views
How to use wordpress function wp_enqueue_script() in php?
I have a php function as shown below. The following function is being used at many places. function render_brightcove_player($active_feed, $poster_image = false) { $poster = ''; if ($...
1vote
2answers
470views
Deregistering a script in Wordpress seems impossible
I tried everything. I even removed all content in functions.php and created a whole new file with just this: function wpdocs_dequeue_script() { if (is_singular()) { wp_dequeue_script( 'gdrts-...
0votes
1answer
81views
How to make sure, that only the selected post is changing?
So I was able to save the content of each post in an array, thanks to a very good answer on it: How to localize value of posts I just copied the solution here: function register_and_enqueue_script() ...
0votes
1answer
1kviews
url_to_postid returns 0
I'm trying to send the post id to js file to create a localStorage for each post by using their id's as the key. The problem is when i try this code in php it returns 0, as a result all my pages have ...
0votes
1answer
1kviews
Getting a variable inside foreach from PHP to JS after localization
I believe I have properly enqueue'ed and localized my script - I've got $q showing up in the DOM. Now I'm sure I'm missing the simple last step to accessing a variable in the JS function. Here's my ...
1vote
0answers
156views
Wordpress Scripts Being Loaded in Footer
I've bought a theme for a Wordpress site. I noticed that the theme author has added the javascript to the footer for load time, but as I use Gravity forms, I understand that some of scripts need to ...
0votes
1answer
2kviews
'Bones' theme: Load stock scripts in footer instead of header?
I'm using the 'Bones' theme in my latest WordPress site, and when I run the site through Google PageSpeed, I receive the following error: Eliminate render-blocking JavaScript and CSS in above-the-...
0votes
2answers
1kviews
Is the wp_enqueue method efficient?
I had a quick question regarding how you are supposed to load in scripts with Wordpress. I am developing a theme and I know that the best way to do this is to use the "wp_register_script/...